#include <iostream>
#include <string>
using namespace std;
int t;
string s[10];
int main(){
	cin >> t;
	while(t--){
		string s1 = "";
		for (int i = 0; i < 8; i++){
			cin >> s[i];
		}
		for (int i = 0; i < 8; i++){
			for (int j = 0; j < s[i].size(); j++){
				if (s[i][j] != '.'){
					s1 += s[i][j];
				}
			}
		}
		cout << s1 << endl;
		
	} 
	

    return 0;
}


